From d38f4e1a8c5083e6146e160d945ad20986ff68ea Mon Sep 17 00:00:00 2001 From: robertl Date: Mon, 20 Jun 2005 14:58:38 +0000 Subject: [PATCH] Etienne TASSE adds ability to read Vito Navigator .SMT tracks. --- gpsbabel/Makefile | 6 +- gpsbabel/README | 7 ++ gpsbabel/msvc/GPSBabel.dsp | 4 + gpsbabel/testo | 7 ++ gpsbabel/vecs.c | 9 +- gpsbabel/vitosmt.c | 167 +++++++++++++++++++++++++++++++++++++ 6 files changed, 196 insertions(+), 4 deletions(-) create mode 100644 gpsbabel/vitosmt.c diff --git a/gpsbabel/Makefile b/gpsbabel/Makefile index 733986566..f2a2847cd 100644 --- a/gpsbabel/Makefile +++ b/gpsbabel/Makefile @@ -28,7 +28,7 @@ FMTS=magproto.o gpx.o geo.o mapsend.o mapsource.o garmin_tables.o \ ozi.o nmea.o text.o html.o palmdoc.o netstumbler.o hsa_ndv.o \ igc.o brauniger_iq.o shape.o hiketech.o glogbook.o coastexp.o \ vcf.o overlay.o kml.o google.o lowranceusr.o an1.o tomtom.o \ - tef_xml.o maggeo.o pathaway.o + tef_xml.o maggeo.o pathaway.o vitosmt.o FILTERS=position.o duplicate.o arcdist.o polygon.o smplrout.o reverse_route.o sort.o stackfilter.o @@ -91,8 +91,8 @@ dep: (echo -n "internal_styles.c: mkstyle.sh " ; echo style/*.style ; /bin/echo -e '\t./mkstyle.sh > internal_styles.c || (rm -f internal_styles.c ; exit 1)' ) >> /tmp/dep echo Edit Makefile and bring in /tmp/dep -VERSIONU=1_2_6-beta06082005 -VERSIOND=1.2.6_beta06082005 +VERSIONU=1_2_6-beta06162005b-isaac +VERSIOND=1.2.6_beta06162005b-isaac # VERSIONU=1_2_5 # VERSIOND=1.2.5 diff --git a/gpsbabel/README b/gpsbabel/README index 164cb44fa..c2ea75c7d 100644 --- a/gpsbabel/README +++ b/gpsbabel/README @@ -839,6 +839,13 @@ THE FORMATS the icon. It should be 22x22 and 16 colors, and have the same name (not including the extension) as the .ov2 file. + VitoSMT + + Vito Navigator II is a Pocket PC GPS application. This format reads + a Vito Navigator II .SMT track file in waypoint mode. It is still + a work in progress. + + DATA FILTERS GPSBabel supports data filtering. Data filters are invoked from diff --git a/gpsbabel/msvc/GPSBabel.dsp b/gpsbabel/msvc/GPSBabel.dsp index 45f765dee..74d347e22 100644 --- a/gpsbabel/msvc/GPSBabel.dsp +++ b/gpsbabel/msvc/GPSBabel.dsp @@ -315,6 +315,10 @@ SOURCE=..\cetus.c # End Source File # Begin Source File +SOURCE=..\vitosmt.c +# End Source File +# Begin Source File + SOURCE=..\coastexp.c # End Source File # Begin Source File diff --git a/gpsbabel/testo b/gpsbabel/testo index 7b931e87b..1aca1f04a 100755 --- a/gpsbabel/testo +++ b/gpsbabel/testo @@ -707,4 +707,11 @@ rm -f ${TMPDIR}/pathaway* ${PNAME} -t -i pathaway -f reference/track/pathaway.pdb -o gpx -F ${TMPDIR}/pathaway.gpx compare ${TMPDIR}/pathaway.gpx reference/track/pathaway.gpx +# +# Vito Navigator II .smt tests +# +rm -f ${TMPDIR}/vitosmt* +${PNAME} -i vitosmt -f reference/vitosmt.smt -o gpx -F ${TMPDIR}/vitosmt.gpx +compare ${TMPDIR}/vitosmt.gpx reference/vitosmt.gpx + exit 0 diff --git a/gpsbabel/vecs.c b/gpsbabel/vecs.c index f524990c9..388cd2d1f 100644 --- a/gpsbabel/vecs.c +++ b/gpsbabel/vecs.c @@ -82,6 +82,7 @@ extern ff_vecs_t an1_vecs; extern ff_vecs_t tomtom_vecs; extern ff_vecs_t tef_xml_vecs; extern ff_vecs_t ppdb_vecs; +extern ff_vecs_t vitosmt_vecs; static vecs_t vec_list[] = { @@ -398,6 +399,12 @@ vecs_t vec_list[] = { "PathAway Palm Database", "pdb" }, + { + &vitosmt_vecs, + "vitosmt", + "Vito Navigator II tracks", + "smt" + }, { NULL, NULL, @@ -588,7 +595,7 @@ alpha (const void *a, const void *b) const vecs_t *const *ap = a; const vecs_t *const *bp = b; - return strcasecmp((*ap)->desc , (*bp)->desc); + return case_ignore_strcmp((*ap)->desc , (*bp)->desc); } /* diff --git a/gpsbabel/vitosmt.c b/gpsbabel/vitosmt.c new file mode 100644 index 000000000..c6af5c54b --- /dev/null +++ b/gpsbabel/vitosmt.c @@ -0,0 +1,167 @@ +/* + Read Vito Navigator .SMT tracks + + Copyright (C) 2005 Etienne TASSE + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA + + */ + +#include +#include +#include + +#define MYNAME "vitosmt" +#include "defs.h" + +FILE *infile; + +static unsigned long +ReadLong(FILE * f) +{ + gbuint32 result = 0; + + fread(&result, sizeof (result), 1, f); + return le_read32(&result); +} + +static double +ReadDouble(FILE * f) +{ + /* unsigned char result[8] = "\0\0\0\0\0\0\0\0"; */ + double result=0; + + fread(&result, sizeof (result), 1, f); + return result; +} + + +static unsigned char * +ReadRecord(FILE * f, + unsigned long size) +{ + unsigned char *result = (unsigned char *) xmalloc(size); + + fread(result, size, 1, f); + return result; +} + +static void +Skip(FILE * f, + unsigned long distance) +{ + fseek(f, distance, SEEK_CUR); +} + +static void +rd_init(const char *fname) +{ + infile = xfopen(fname, "rb", MYNAME); +} + +static void +rd_deinit(void) +{ + fclose(infile); +} + +static void +vitosmt_read(void) +{ + unsigned short version =0; + unsigned long count =0; + const unsigned long recsize =64; + unsigned short stringlen =0; + static int serial =0; + +/* route_head *track_head =0; */ + waypoint *wpt_tmp =0; + double latrad =0; + double lonrad =0; + double elev =0; + unsigned char* timestamp =0; + struct tm tmStruct ={0,0,0,0,0,0,0,0,0}; + + /* + * 24 bytes header + */ + version = ReadLong(infile); /* 2 */ + ReadLong(infile); /* 1000 */ + count = ReadLong(infile); /* 600 */ + ReadLong(infile); /* 0 */ + ReadLong(infile); /* 599 */ + ReadLong(infile); /* 600 */ + +/* track_head = route_head_alloc(); */ +/* route_add_head(track_head); */ + + + while (count) { + /* + * 64 bytes of data + */ + latrad =ReadDouble(infile); /* WGS84 latitude in radians */ + lonrad =ReadDouble(infile); /* WGS84 longitude in radians */ + elev =ReadDouble(infile); /* elevation in meters */ + timestamp =ReadRecord(infile,8); /* local time */ + Skip(infile,32); /* remainder, unknown fmt */ + + wpt_tmp = waypt_new(); + + wpt_tmp->latitude =(latrad * 180) / M_PI; + wpt_tmp->longitude =(lonrad * 180) / M_PI; + wpt_tmp->altitude =elev; + + tmStruct.tm_year =timestamp[0]+100; + tmStruct.tm_mon =timestamp[1]-1; + tmStruct.tm_mday =timestamp[2]; + tmStruct.tm_hour =timestamp[3]; + tmStruct.tm_min =timestamp[4]; + tmStruct.tm_sec =timestamp[5]; + tmStruct.tm_isdst =-1; + + wpt_tmp->creation_time = mktime(&tmStruct); /* + get_tz_offset(); */ + + wpt_tmp->shortname = (char *) xmalloc(10); + snprintf(wpt_tmp->shortname, 10, "SMT%04d",++serial); + wpt_tmp->wpt_flags.shortname_is_synthetic = 1; + + waypt_add(wpt_tmp); + + xfree(timestamp); + + + count--; + } +} + +static void +wr_init(const char *fname) +{ + fatal(MYNAME ":Not enough information is known about this format to write it.\n"); +} + +ff_vecs_t vitosmt_vecs = { + ff_type_file, + { ff_cap_read, ff_cap_read, ff_cap_none}, + rd_init, + wr_init, + rd_deinit, + NULL, + vitosmt_read, + NULL, + NULL, + NULL +}; -- 2.30.2